import 'package:hc_ui/config/hc_default_theme_config.dart';
import 'package:hc_ui/theme/hc_avatar_theme.dart';
import 'package:hc_ui/theme/hc_cell_group_theme.dart';
import 'package:hc_ui/theme/hc_cell_theme.dart';
import 'package:hc_ui/theme/hc_common_theme.dart';
import 'package:hc_ui/theme/hc_empty_theme.dart';

import 'hc_avatar_gird_theme.dart';
import 'hc_button_panel_theme.dart';
import 'hc_button_theme.dart';
import 'hc_dialog_theme.dart';
import 'hc_notice_bar_theme.dart';
import 'hc_tag_theme.dart';
import 'hc_title_theme.dart';
import 'hc_toast_theme.dart';

class HcAllTheme {
  //通用的主题配置
  HcCommonTheme? _commonTheme;

  // 头像的主题
  HcAvatarTheme? _avatarTheme;

  HcAvatarGridTheme? _avatarGridTheme;

  //按钮的主题配置
  HcButtonTheme? _buttonTheme;
  HcButtonPanelTheme? _buttonPanelTheme;

  //单元格的主题配置
  HcCellTheme? _cellTheme;

  //单元格组的主题配置
  HcCellGroupTheme? _cellGroupTheme;

  // 弹窗的主题
  HcDialogTheme? _dialogTheme;

  HcEmptyTheme? _emptyTheme;

  //标题的主题配置
  HcTitleTheme? _titleTheme;

  //弹窗的主题
  HcToastTheme? _toastTheme;

  //tag的配置样式
  HcTagTheme? _tagTheme;

  //通知Bar的主题
  HcNoticeBarTheme? _noticeBarTheme;

  HcAllTheme(
      {HcAvatarTheme? avatarTheme,
      HcAvatarGridTheme? avatarGridTheme,
      HcButtonTheme? buttonTheme,      HcButtonPanelTheme? buttonPanelTheme,

        HcCellTheme? cellTheme,
      HcCellGroupTheme? cellGroupTheme,
      HcCommonTheme? commonTheme,
      HcDialogTheme? dialogTheme,
      HcEmptyTheme? emptyTheme,
      HcTitleTheme? titleTheme,
      HcToastTheme? toastTheme,
      HcTagTheme? tagTheme,
      HcNoticeBarTheme? noticeBarTheme})
      : _avatarTheme = avatarTheme,
        _avatarGridTheme = avatarGridTheme,
        _buttonTheme = buttonTheme,
        _buttonPanelTheme = buttonPanelTheme,

      _cellTheme = cellTheme,
        _cellGroupTheme = cellGroupTheme,
        _commonTheme = commonTheme,
        _dialogTheme = dialogTheme,
        _emptyTheme = emptyTheme,
        _titleTheme = titleTheme,
        _toastTheme = toastTheme,
        _tagTheme = tagTheme,
        _noticeBarTheme = noticeBarTheme;

  void initTheme() {
    _commonTheme ??= HcCommonTheme();
    _avatarTheme ??= HcAvatarTheme();
    _avatarGridTheme ??= HcAvatarGridTheme();
    _buttonTheme ??= HcButtonTheme();
    _buttonPanelTheme ??= HcButtonPanelTheme();

    _cellTheme ??= HcCellTheme();
    _cellGroupTheme ??= HcCellGroupTheme();
    _dialogTheme ??= HcDialogTheme();
    _emptyTheme = HcEmptyTheme();
    _titleTheme ??= HcTitleTheme();
    _toastTheme ??= HcToastTheme();
    _tagTheme ??= HcTagTheme();
    _noticeBarTheme ??= HcNoticeBarTheme();
    commonTheme.initTheme();
    avatarTheme.initTheme(tempTheme: commonTheme);
    avatarGridTheme.initTheme(tempTheme: commonTheme);
    buttonTheme.initTheme(tempTheme: commonTheme);
    buttonPanelTheme.initTheme(tempTheme: commonTheme);

    cellTheme.initTheme(tempTheme: commonTheme);
    cellGroupTheme.initTheme(tempTheme: commonTheme);
    dialogTheme.initTheme(tempTheme: commonTheme);
    emptyTheme.initTheme(tempTheme: commonTheme);
    titleTheme.initTheme(tempTheme: commonTheme);
    toastTheme.initTheme(tempTheme: commonTheme);
    tagTheme.initTheme(tempTheme: commonTheme);
    noticeBarTheme.initTheme(tempTheme: commonTheme);
  }

  HcAvatarTheme get avatarTheme =>
      _avatarTheme ?? HcDefaultThemeConfig.defaultAvatarTheme;

  HcAvatarGridTheme get avatarGridTheme =>
      _avatarGridTheme ?? HcDefaultThemeConfig.defaultAvatarGridTheme;

  HcButtonTheme get buttonTheme =>
      _buttonTheme ?? HcDefaultThemeConfig.defaultButtonTheme;
  HcButtonPanelTheme get buttonPanelTheme =>
      _buttonPanelTheme ?? HcDefaultThemeConfig.defaultButtonPanelTheme;
  HcCellTheme get cellTheme =>
      _cellTheme ?? HcDefaultThemeConfig.defaultCellTheme;

  HcCellGroupTheme get cellGroupTheme =>
      _cellGroupTheme ?? HcDefaultThemeConfig.defaultCellGroupTheme;

  HcCommonTheme get commonTheme =>
      _commonTheme ?? HcDefaultThemeConfig.defaultCommonTheme;

  HcDialogTheme get dialogTheme =>
      _dialogTheme ?? HcDefaultThemeConfig.defaultDialogTheme;

  HcEmptyTheme get emptyTheme => _emptyTheme?? HcDefaultThemeConfig.defaultEmptyTheme;

  HcTitleTheme get titleTheme =>
      _titleTheme ?? HcDefaultThemeConfig.defaultTitleTheme;

  HcToastTheme get toastTheme =>
      _toastTheme ?? HcDefaultThemeConfig.defaultToastTheme;

  HcTagTheme get tagTheme => _tagTheme ?? HcDefaultThemeConfig.defaultTagTheme;

  HcNoticeBarTheme get noticeBarTheme =>
      _noticeBarTheme ?? HcDefaultThemeConfig.defaultNoticeBarTheme;
}
